import request from '@/config/axios'

// 考勤规则 VO
export interface AttendanceRuleVO {
  id: number // 规则ID
  ruleName: string // 规则名称
  amStartTime: string // 上午考勤开始时间
  amEndTime: string // 上午考勤结束时间
  pmStartTime: number // 下午开始时间
  pmEndTime: number // 下午结束时间
  remark: string // 备注
  leaveCostHours: number // 请假一天消耗的加班时长（小时）
}

// 考勤规则 API
export const AttendanceRuleApi = {
  // 查询考勤规则分页
  getAttendanceRulePage: async (params: any) => {
    return await request.get({ url: `/oa/attendance-rule/page`, params })
  },

  // 查询考勤规则详情
  getAttendanceRule: async (id: number) => {
    return await request.get({ url: `/oa/attendance-rule/get?id=` + id })
  },

  // 新增考勤规则
  createAttendanceRule: async (data: AttendanceRuleVO) => {
    return await request.post({ url: `/oa/attendance-rule/create`, data })
  },

  // 修改考勤规则
  updateAttendanceRule: async (data: AttendanceRuleVO) => {
    return await request.put({ url: `/oa/attendance-rule/update`, data })
  },

  // 删除考勤规则
  deleteAttendanceRule: async (id: number) => {
    return await request.delete({ url: `/oa/attendance-rule/delete?id=` + id })
  },

  // 导出考勤规则 Excel
  exportAttendanceRule: async (params) => {
    return await request.download({ url: `/oa/attendance-rule/export-excel`, params })
  },
}
